﻿
Public MustInherit Class XBRLCollection
    Inherits System.Collections.CollectionBase
    Dim mytype As Type

    Public Sub New(ByRef mytype As Type)
        Me.mytype = mytype
    End Sub


    Public Function Add()
        Dim obj As sqlTable
        obj = Activator.CreateInstance(mytype)
        List.Add(obj)
        Return obj
    End Function

    Public Sub Add(ByRef obj As sqlTable)
        '        Dim testobj As Object = TryCast(obj, mytype)
        '        If testobj Is Nothing Then Exit Sub
        List.Add(obj)
    End Sub

    Public Sub AddAt(ByVal index As Integer, ByRef obj As sqlTable)
        List.Insert(index, obj)
    End Sub

    Public Sub Remove(ByVal index As Integer)
        If index > Count - 1 Or index < 0 Then
        Else
            List.RemoveAt(index)
        End If
    End Sub

    Public Sub Remove(ByRef obj As sqlTable)
        List.RemoveAt(Me.List.IndexOf(obj))
    End Sub

    Public ReadOnly Property Item(ByVal index As Integer) As sqlTable
        Get
            '            Return CType(List.Item(index), document)
            Return List.Item(index)
        End Get
    End Property

End Class











Public Class accession
    Inherits sqlTable
    Public Sub New()
        MyBase.new("accession")
        tableDescription = "The accession table contains a row for each filing (also known as an 'accession') that is in the database."
    End Sub



    '    Name Type Nulls Default Description
    Public accession_id As Integer   'No , Primary key.
    Public filing_date As Date  'No   The date the filing was accepted by the SEC.
    Public entity_id As Integer   'No The id for the entity table. This corresponds to the entity for the accession.
    Public creation_software As String   'Yes    This field identifies the software that was used to create the filing. This information is determined by reading comments in the xbrl instance file of the filing. Not all software creation tools put this information in the files that are generated.
    Public standard_industrial_classification As Integer  'No   -1   The SIC code provided when the filing was submitted to the SEC. This information is read from the RSS feed.
    Public state_of_incorporation As String   'Yes The state where the entity is incorporated. This information is read from the RSS feed.
    Public internal_revenue_service_number As Integer   'No -1 The IRS identification number for the entity. This information is read from the web page for the filing.
    Public business_address As String   'Yes The business address of the entity at the time of the filing.
    Public business_phone As String 'Yes The phone number of the entity at the time of the filing.
    Public sec_html_url As String ' Yes  The URL for the SEC web page for the filing.
    Public entry_url As String ' Yes The URL for the XBRL instance document for the filing
    Public filing_accession_number As String  'No The filing accession number for the filing. This is the SEC’s identifier for the filing.
    Public accepted_timestamp As Date 'timestamp without time zone  Yes now()  The date and time that the filing was accepted by the SEC. This information is from the RSS feed. If the accepted time stamp is not provided, then it will be the date and time that the filing was processed in the XBRL US Database.
    Public zip_url As String ' Yes The URL to a zip file on the SEC website that contains all of the XBRL files (instance and taxonomy).
    Public restatement_index As Integer 'Yes Identifies if the filing is a restatement. The most recent statement of a filing will be “1”. The next most recent statement of a filing will be “2”, and so on. When a filing is first received, it is assigned a restatement index of “1”. If the filing is later restated, the index of the original filing is bumped up to “2” and the restatement index of the new (restated) filing is “1”. “1” will always represent the most current filing in the set of original and restated filings. This is useful when querying for data when only the most current statement of the data is desired, which is the usual case. The restatement index can be used to see how values change as the filing is restated.
    Public period_index As Integer 'Yes  Identifies the most recent filing for the entity. This is similar to the restatement index, where as each filing is processed, the period indexes of the previous filings are bumped up by 1.



    Public Overrides Sub fillFieldList()
        Dim t As Type = Me.GetType
        fields.Add("accession_id", "Primary key.", t)
        fields.Add("filing_date", "The date the filing was accepted by the SEC.", t)
        fields.Add("entity_id", "The id for the entity table. This corresponds to the entity for the accession.", t)
        fields.Add("creation_software", "This field identifies the software that was used to create the filing. This information is determined by reading comments in the xbrl instance file of the filing. Not all software creation tools put this information in the files that are generated.", t)
        fields.Add("standard_industrial_classification", "The SIC code provided when the filing was submitted to the SEC. This information is read from the RSS feed.", t)
        fields.Add("state_of_incorporation", "The state where the entity is incorporated. This information is read from the RSS feed.", t)
        fields.Add("internal_revenue_service_number", "The IRS identification number for the entity. This information is read from the web page for the filing.", t)
        fields.Add("business_address", "The business address of the entity at the time of the filing.", t)
        fields.Add("business_phone", "The phone number of the entity at the time of the filing.", t)
        fields.Add("sec_html_url", "The URL for the SEC web page for the filing.", t)
        fields.Add("entry_url", "The URL for the XBRL instance document for the filing", t)
        fields.Add("filing_accession_number", "The filing accession number for the filing. This is the SEC’s identifier for the filing.", t)
        fields.Add("accepted_timestamp", "The date and time that the filing was accepted by the SEC. This information is from the RSS feed. If the accepted time stamp is not provided, then it will be the date and time that the filing was processed in the XBRL US Database.", t)
        fields.Add("zip_url", "The URL to a zip file on the SEC website that contains all of the XBRL files (instance and taxonomy).", t)
        fields.Add("restatement_index", "Identifies if the filing is a restatement. The most recent statement of a filing will be '1'. The next most recent statement of a filing will be '2', and so on. When a filing is first received, it is assigned a restatement index of '1. If the filing is later restated, the index of the original filing is bumped up to '2' and the restatement index of the new (restated) filing is '1'. '1' will always represent the most current filing in the set of original and restated filings. This is useful when querying for data when only the most current statement of the data is desired, which is the usual case. The restatement index can be used to see how values change as the filing is restated.", t)
        fields.Add("period_index", "Identifies the most recent filing for the entity. This is similar to the restatement index, where as each filing is processed, the period indexes of the previous filings are bumped up by 1.", t)



    End Sub




    Public Overrides Sub fillLinkTables()
        linkTables.Clear()

        linkTables.Add("accession_id", "accession_document_association", "accession_id")
        linkTables.Add("accession_id", "accession_timestamp", "accession_id")
        linkTables.Add("accession_id", "context", "accession_id")
        linkTables.Add("accession_id", "fact", "accession_id")
        linkTables.Add("accession_id", "network", "accession_id")
        linkTables.Add("accession_id", "unit", "accession_id")
        linkTables.Add("entity_id", "entity", "entity_id")

    End Sub






End Class
Public Class accessions
    Inherits XBRLCollection
    Public Sub New()
        MyBase.New(GetType(accession))
    End Sub
End Class


Public Class accession_document_association
    Inherits sqlTable
    Public Sub New()
        MyBase.new("accession_document_association")
        tableDescription = "The accession_document_association table is the join table between the accession table and the document table. There is a many to many relationship between these tables. It links accessions to the names of the physical XBRL files of the filing. The list of documents for an accession includes the submitted XBRL instance document and all the documents that support the instance in the DTS."
    End Sub

    Public accession_document_association_id As Integer 'No   Primary key.   //incorrect name in doc
    Public accession_id As Integer 'No   Foreign key to the accession table.
    Public document_id As Integer   'No  Foreign key to the document table.

    Public Overrides Sub fillFieldList()
        Dim t As Type = Me.GetType
        fields.Add("accession_document_association_id", "Primary key.", t)   ' incorrect name in doc
        fields.Add("accession_id", "Foreign key to the accession table.", t)
        fields.Add("document_id", "Foreign key to the document table.", t)
    End Sub



    Public Overrides Sub fillLinkTables()
        linkTables.Clear()
        linkTables.Add("accession_id", "accession", "accession_id")
        linkTables.Add("document_id", "document", "document_id")
    End Sub





End Class
Public Class accession_timestamp
    Inherits sqlTable
    Public Sub New()
        MyBase.new("accession_timestamp")
        tableDescription = "The accession_timestamp table identifies when the filing was added to the XBRL US Database. It uses the same primary key as the accession table."

    End Sub

    Public accession_id As Integer ' No  Primary key. This is also a foreign key to the accession table.
    Public creation_time As Date 'time stamp with time zone  Yes    now()   The date time when the is database updated for the filing. This field is updated via a trigger on the accession table. The default creates the timestamp.

    Public Overrides Sub fillFieldList()
        Dim t As Type = Me.GetType
        fields.Add("accession_id", "Primary key. This is also a foreign key to the accession table.", t)
        fields.Add("creation_time", "The date time when the is database updated for the filing. This field is updated via a trigger on the accession table. The default creates the timestamp.", t)
    End Sub

    Public Overrides Sub fillLinkTables()
        linkTables.Clear()
        linkTables.Add("accession_id", "accession", "accession_id")
    End Sub

End Class
Public Class attribute_value
    Inherits sqlTable
    Public Sub New()
        MyBase.new("attribute_value")
        tableDescription = "The attribute_value table lists the attribute names and values for an element. There is a many to many relationship between attributes and the elements (via the join table element_attribute_value_associaton)."

    End Sub


    Public attribute_value_id As Integer 'No	Primary key.
    Public qname_id As Integer 'No	The id of the qname for the attribute name.
    Public text_value As String 'No	The value of the attribute

    Public Overrides Sub fillFieldList()
        Dim t As Type = Me.GetType
        fields.Add("attribute_value_id", "Primary key.", t)
        fields.Add("qname_id", "The id of the qname for the attribute name.", t)
        fields.Add("text_value", "The value of the attribute", t)
    End Sub




    Public Overrides Sub fillLinkTables()
        linkTables.Clear()
        linkTables.Add("qname_id", "qname", "qname_id")
        'not in doc
        linkTables.Add("attribute_value_id", "element_attribute_value_association", "attribute_value_id")
    End Sub

End Class
Public Class context
    Inherits sqlTable
    Public Sub New()
        MyBase.new("context")
        tableDescription = "The context table lists the XBRL contexts that are used in the instance documents of the filings. There is a row for each context. The context is significant in that it contains the contextual information (period, entity, and dimensional information) for the facts in an instance." & vbCrLf & vbCrLf & "The period information is contained in the 'period_start' and 'period_end' fields if the context represents a duration and the 'period_instant' if the context represents an instant. In the special case when the period of the context is the 'forever' duration, all three fields will be null." & vbCrLf & vbCrLf & "The context contains entity information as identified by the 'entity_scheme' and 'entity_identifier' fields. The EDGAR Filer Manual specifies that the entity identifier is the entity CIK. However, there is also an entity table which includes the entity name and the CIK (Central Index Key)."

    End Sub

    Public context_id As Integer 'No	Primary key.
    Public accession_id As Integer 'No	The id of the filing (accession) that the context comes from.
    Public period_start As Date    'Yes	If the context represents a duration period, this is the start date of the duration. Otherwise, this field is null.
    Public period_end As Date    'Yes	If the context represents a duration period, this is the end date of the duration. Otherwise, this field is null. When an end date is reported in XBRL without a time portion, it is assumed to be the end of day. In the database this translates to midnight (at the beginning) of the following day, This field will have this effective end date. This will always be one day after the end date in the XBRL context.
    Public period_instant As Date    'Yes	If the context represents an instant period, this is the date of the instant. Otherwise, this field is null. When an instant date is reported in XBRL without a time portion, it is assumed to be the end of day. In the database this translates to midnight (at the beginning) of the following day, This field will have this effective instant date. This will always be one day after the instant date in the XBRL context.
    Public specifies_dimensions As Boolean 'No	Identifies if the context includes XBRL dimensional qualifications. If so, the dimensional qualifications are in the context_dimension table.
    Public context_xml_id As String 'No	The XML id of the context element in the instance document.
    Public entity_scheme As String 'No	The scheme of the entity identifier from the context.
    Public entity_identifier As String 'No	The entity identifier from the context.

    Public Overrides Sub fillFieldList()
        Dim t As Type = Me.GetType
        fields.Add("context_id", "Primary key.", t)
        fields.Add("accession_id", "The id of the filing (accession) that the context comes from.", t)
        fields.Add("period_start", "If the context represents a duration period, this is the start date of the duration. Otherwise, this field is null.", t)
        fields.Add("period_end", "If the context represents a duration period, this is the end date of the duration. Otherwise, this field is null. When an end date is reported in XBRL without a time portion, it is assumed to be the end of day. In the database this translates to midnight (at the beginning) of the following day, This field will have this effective end date. This will always be one day after the end date in the XBRL context.", t)
        fields.Add("period_instant", "If the context represents an instant period, this is the date of the instant. Otherwise, this field is null. When an instant date is reported in XBRL without a time portion, it is assumed to be the end of day. In the database this translates to midnight (at the beginning) of the following day, This field will have this effective instant date. This will always be one day after the instant date in the XBRL context.", t)
        fields.Add("specifies_dimensions", "Identifies if the context includes XBRL dimensional qualifications. If so, the dimensional qualifications are in the context_dimension table.", t)
        fields.Add("context_xml_id", "The XML id of the context element in the instance document.", t)
        fields.Add("entity_scheme", "The scheme of the entity identifier from the context.", t)
        fields.Add("entity_identifier", "The entity identifier from the context.", t)
    End Sub





    Public Overrides Sub fillLinkTables()
        linkTables.Clear()
        linkTables.Add("accession_id", "accession", "accession_id")
        linkTables.Add("context_id", "fact", "context_id")  '' WAS MISSING FROM PDF DOC
        linkTables.Add("context_id", "context_aug", "context_id") '' WAS MISSING FROM PDF DOC
        linkTables.Add("context_id", "context_dimension", "context_id") '' WAS MISSING FROM PDF DOC


    End Sub

End Class
Public Class context_aug
    Inherits sqlTable
    Public Sub New()
        MyBase.new("context_aug")
        tableDescription = "The context_aug table contains additional information based on the information in the context table. There is a one-to-one relationship between the context_aug and context tables." & vbCrLf & vbCrLf & "The additional information is the calculated fiscal year and period based on the context period. These values are calculated by using the entities’ month/day yearend based on the CurrentFiscalYearEndDate concept from the DEI (Document Entity Information) taxonomy. As per the EDGAR Filer Manual, this concept is required for 10-Q and 10-K filings. However, if the CurrentFiscalYearEndDate is not supplied in the filing that contains the context, the calculation will look for a previous filed version of CurrentFiscalYearEndDate to make the fiscal year and period calculation. See the Fiscal functions for more information about how the fiscal year and period is calculated."
    End Sub

    Public context_id As Integer 'No	Primary key. Identical to the context_id on the context table.
    Public fiscal_year As Integer 'Yes	Fiscal year for the period of the context. For duration periods, the fiscal year is based on the end date of the duration. For forever periods, the fiscal year is null. If the fiscal year cannot be calculated, the value will be null. This can happen if the month/day end for the fiscal year cannot be obtained.
    Public fiscal_period As String  'Yes	Fiscal period for the period of the context. Possible values are: Y, 1Q, 2Q, 3Q, 4Q, 1H, 2H, 3QCUM. If the fiscal period cannot be determined, this field will be contain the instant date if the period is an instant or the start and end date separated by a “ - “ if the period is a duration.
    'whoops these were not in the doc!
    Public context_hash As String
    Public dimension_hash As String
    Public calendar_year As Integer
    Public calendar_period As String
    Public calendar_start_offset As Decimal
    Public calendar_end_offset As Decimal
    Public calendar_period_size_diff_percentage As Double


    Public Enum fiscalPeriodValues
        'Value           Instant         Duration
        Y = 1  ' Fiscal year end Full Fiscal Year 
        _1Q = 2  ' First quarter end Full first quarter and YTD for first quarter 
        _2Q = 3 'Second quarter end Full second quarter 
        _3Q = 4 'Third quarter end Full third quarter 
        _4Q = 5 'Cannot be assigned for an instant, instead the value is ‘Y’ Full fourth quarter 
        _1H = 6 'Full first half of the fiscal year and YTD for second quarter 
        _2H = 7 'Full second half of the fiscal year 
        _3QCUM = 8  'YTD for third quarter
    End Enum

    Public Overrides Sub fillFieldList()
        Dim t As Type = Me.GetType
        fields.Add("context_id", "Primary key. Identical to the context_id on the context table.", t)
        fields.Add("fiscal_year", "Fiscal year for the period of the context. For duration periods, the fiscal year is based on the end date of the duration. For forever periods, the fiscal year is null. If the fiscal year cannot be calculated, the value will be null. This can happen if the month/day end for the fiscal year cannot be obtained.", t)
        fields.Add("fiscal_period", "Fiscal period for the period of the context. Possible values are: Y, 1Q, 2Q, 3Q, 4Q, 1H, 2H, 3QCUM. If the fiscal period cannot be determined, this field will be contain the instant date if the period is an instant or the start and end date separated by a ' - ' if the period is a duration.", t)

        'not in doc...
        fields.Add("context_hash", "!Not in doc!", t)
        fields.Add("dimension_hash", "!Not in doc!", t)
        fields.Add("calendar_year", "!Not in doc!", t)
        fields.Add("calendar_period", "!Not in doc!", t)
        fields.Add("calendar_start_offset", "!Not in doc!", t)
        fields.Add("calendar_end_offset", "!Not in doc!", t)
        fields.Add("calendar_period_size_diff_percentage", "!Not in doc!", t)



    End Sub




    Public Overrides Sub fillLinkTables()
        linkTables.Clear()
        linkTables.Add("context_id", "context", "context_id")
    End Sub



End Class
Public Class context_dimension
    Inherits sqlTable
    Public Sub New()
        MyBase.new("context_dimension")
        tableDescription = "The context_dimension table lists the XBRL dimensions and dimensional values for a context. There is a one-to-many relationship between the context table and the context_dimension table. Each row represents a single dimensional qualification (dimension name and value) for a given context. This table will include defaulted dimensions, not just the explicated stated dimensions." & vbCrLf & vbCrLf & "The list of dimensions for a context is the full list of dimensions used in the filing, not just those that specifically apply for a fact that uses the context. Therefore, each context in the filing will have the same set of dimensions in the context_dimension table."
    End Sub

    Public context_dimension_id As Integer 'No	Primary key.
    Public context_id As Integer 'No	The id of the context.
    Public dimension_qname_id As Integer 'No	The id of the qname for the dimension concept.
    Public member_qname_id As Integer 'Yes	The id of the qname for the member concept if the member is an explicit member.
    Public typed_qname_id As Integer 'Yes	The id of the typed member element if the member is a typed dimension member.
    Public is_default As Boolean 'No	For explicit dimension, identifies if the dimension is defaulted for the context.
    Public is_segment As Boolean 'Yes	Identifies if the dimensional information comes from the segment portion of the context. If not, then it comes from the scenario portion of the context.
    Public typed_text_content As String  'Yes	For typed dimensions, contains the context of the typed dimension member element (which is identified by the typed_qname_id).

    Public Overrides Sub fillFieldList()
        Dim t As Type = Me.GetType
        fields.Add("context_dimension_id", "Primary key.", t)
        fields.Add("context_id", "The id of the context.", t)
        fields.Add("dimension_qname_id", "The id of the qname for the dimension concept.", t)
        fields.Add("member_qname_id", "The id of the qname for the member concept if the member is an explicit member.", t)
        fields.Add("typed_qname_id", "The id of the typed member element if the member is a typed dimension member.", t)
        fields.Add("is_default", "For explicit dimension, identifies if the dimension is defaulted for the context.", t)
        fields.Add("is_segment", "Identifies if the dimensional information comes from the segment portion of the context. If not, then it comes from the scenario portion of the context.", t)
        fields.Add("typed_text_content", "For typed dimensions, contains the context of the typed dimension member element (which is identified by the typed_qname_id).", t)
    End Sub




    Public Overrides Sub fillLinkTables()
        linkTables.Clear()
        linkTables.Add("context_id", "context", "context_id")
        linkTables.Add("dimension_qname_id", "qname", "qname_id")
        linkTables.Add("member_qname_id", "qname", "qname_id")
        linkTables.Add("typed_qname_id", "qname", "qname_id")
        linkTables.Add("context_id", "fact", "context_id")  ' missing from pdf doc
    End Sub


End Class

Public Class custom_arcrole_type
    Inherits sqlTable
    Public Sub New()
        MyBase.new("custom_arcrole_type")
        tableDescription = "The custom_arcrole_type table lists arc roles that are defined using XBRL arcroleType elements."
    End Sub

    Public custom_arcrole_type_id As Integer 'No	Primary key.
    Public document_id As Integer 'No	The id of the document where the arc role is defined.
    Public uri_id As Integer 'No	The id of the URI for the arc role.
    Public definition As String  'Yes	The text of the definition node from the arcroleType element.
    Public cycles_allowed As XBRL.arcrole_cycles_allowed  'Yes	A code that identifies the level allowable cycle for the arc role: 1 = any  	2 = undirected	'3 = none	These codes are defined in the enumeration_arcrole_cycles_allowed table.

    Public Overrides Sub fillFieldList()
        Dim t As Type = Me.GetType
        fields.Add("custom_arcrole_type_id", "Primary key.", t)
        fields.Add("document_id", "The id of the document where the arc role is defined.", t)
        fields.Add("uri_id", "The id of the URI for the arc role.", t)
        fields.Add("definition", "The text of the definition node from the arcroleType element.", t)
        fields.Add("cycles_allowed", "A code that identifies the level allowable cycle for the arc role: 1 = any  	2 = undirected	3 = none	These codes are defined in the enumeration_arcrole_cycles_allowed table.", t)
    End Sub


    Public Overrides Sub fillLinkTables()
        linkTables.Clear()
        linkTables.Add("document_id", "document", "document_id")
        linkTables.Add("uri_id", "uri", "uri_id")
        linkTables.Add("cycles_allowed", "enumeration_arcrole_cycles_allowed", "enumeration_arcrole_cycles_allowed_id")
    End Sub

End Class
Public Class custom_arcrole_used_on
    Inherits sqlTable
    Public Sub New()
        MyBase.new("custom_arcrole_used_on")
        tableDescription = "The custom_arcrole_used_on table identifies which type of extended link elements can use the custom arc role. There is a one-to-many relationship between the custom_arcrole_type and this table."

    End Sub

    Public custom_arcrole_used_on_id As Integer 'No	Primary key.
    Public custom_arcrole_type_id As Integer 'No	The id of the custom arc role.
    Public qname_id As Integer 'No	The id of the qname of the extended link element that can use the custom arc role.

    Public Overrides Sub fillFieldList()
        Dim t As Type = Me.GetType
        fields.Add("custom_arcrole_used_on_id", "Primary key.", t)
        fields.Add("custom_arcrole_type_id", "The id of the custom arc role.", t)
        fields.Add("qname_id", "The id of the qname of the extended link element that can use the custom arc role.", t)
    End Sub



    Public Overrides Sub fillLinkTables()
        linkTables.Clear()
        linkTables.Add("custom_arcrole_type_id", "custom_arcrole_type", "custom_arcrole_type_id")
        linkTables.Add("qname_id", "qname", "qname_id")
    End Sub


End Class
Public Class custom_role_type
    Inherits sqlTable
    Public Sub New()
        MyBase.new("custom_role_type")
        tableDescription = "The custom_role_type table lists roles that are defined using XBRL roleType elements."
    End Sub

    Public custom_role_type_id As Integer 'No	Primary key.
    Public document_id As Integer 'No	The id of the document where the role is defined.
    Public uri_id As Integer 'No	The id of the URI for the role.
    Public definition As String  'Yes	The text of the definition node from the roleType element.

    Public Overrides Sub fillFieldList()
        Dim t As Type = Me.GetType
        fields.Add("custom_role_type_id", "Primary key.", t)
        fields.Add("document_id", "The id of the document where the role is defined.", t)
        fields.Add("uri_id", "The id of the URI for the role.", t)
        fields.Add("definition", "The text of the definition node from the roleType element.", t)
    End Sub

    Public Overrides Sub fillLinkTables()
        linkTables.Clear()
        linkTables.Add("document_id", "document", "document_id")
        linkTables.Add("uri_id", "uri", "uri_id")
    End Sub



End Class
Public Class custom_role_used_on
    Inherits sqlTable
    Public Sub New()
        MyBase.new("custom_role_used_on")
        tableDescription = "The custom_role_used_on table identifies which type of extended link elements can use the custom role. There is a one-to-many relationship between the custom_role_type and this table."
    End Sub

    Public custom_role_used_on_id As Integer 'No	Primary key.
    Public custom_role_type_id As Integer 'No	The id of the custom role.
    Public qname_id As Integer 'No	The id of the qname of the extended link element that can use the custom role.

    Public Overrides Sub fillFieldList()
        Dim t As Type = Me.GetType
        fields.Add("custom_role_used_on_id", "Primary key.", t)
        fields.Add("custom_role_type_id", "The id of the custom role.", t)
        fields.Add("qname_id", "The id of the qname of the extended link element that can use the custom role.", t)
    End Sub

    Public Overrides Sub fillLinkTables()
        linkTables.Clear()
        linkTables.Add("custom_role_type_id", "custom_role_type", "custom_role_type_id")
        linkTables.Add("qname_id", "qname", "qname_id")
    End Sub



End Class
Public Class document
    Inherits sqlTable
    Public Sub New()
        MyBase.new("document")
        tableDescription = "The document table lists the XBRL files that make up all of the DTSs that are used in the filings. This includes the files that are submitted to the SEC and all files that are used to make up the complete DTS. This will include the SEC authorized taxonomy files (e.g. US GAAP taxonomy files) that can be referenced. Only those files that make up the DTS of a filing are included. So in the case of the US GAAP taxonomy files, only the files that define concepts are included."
    End Sub

    Public document_id As Integer 'No	Primary key.
    Public document_uri As String  'No	The URI of the document. This is the absolute URL for the document location. For filer’s files, it will be the location of the file on the SEC’s website.

    Public Overrides Sub fillFieldList()
        Dim t As Type = Me.GetType
        fields.Add("document_id", "Primary key.", t)
        fields.Add("document_uri", "The URI of the document. This is the absolute URL for the document location. For filer’s files, it will be the location of the file on the SEC’s website.", t)
    End Sub

    Public Overrides Sub fillLinkTables()
        linkTables.Clear()
        linkTables.Add("document_id", "accession_document_association", "document_id")  ' this one was left out!!!!
        linkTables.Add("document_id", "custom_arcrole_type", "document_id")
        linkTables.Add("document_id", "custom_role_type", "document_id")
        linkTables.Add("document_id", "element", "document_id")
        linkTables.Add("document_id", "resource", "document_id")
    End Sub


End Class
Public Class element
    Inherits sqlTable
    Public Sub New()
        MyBase.new("element")
        tableDescription = "The element table lists all the elements defined in an XML schema in the DTSs of the filings. This includes all primary concepts, hypercube concepts, dimension concepts, member concepts. It will also include non-XBRL concept elements."
    End Sub

    Public element_id As Integer 'No	Primary key.
    Public qname_id As Integer 'No	The id of the QName for the element.
    Public datatype_qname_id As Integer 'Yes	The id of the QName of the element’s type.
    Public xbrl_base_datatype_qname_id As Integer 'Yes	The id of the QName of the element’s base data type. This is the XBRL type that the element’s type is based upon. If the element directly uses an XBRL type, then this will be the same as the datatype_qname_id.
    Public balance_id As XBRL.element_balance  'Yes	A code for the balance type of the element: 1 = debit 2 = credit These codes are defined in the enumeration_element_balance table. If there is no balance type, then this field is null. 
    Public period_type_id As XBRL.element_period_type  'No	A code for the period type of the element: 1 = instant 2 = duration 3 = forever These codes are defined in the enumeration_element_period_type table. 
    Public substitution_group_qname_id As Integer 'Yes	The id of the QName of the element’s substitution group.
    Public abstract As Boolean 'No	Identifies if the element is defined as an abstract element.
    Public nillable As Boolean 'No	Identifies if the xsi:nillable attribute is set to true.
    Public document_id As Integer 'No	The id of the document where the element is defined.
    Public is_numeric As Boolean 'No	Identifies if the element defines a numeric data type.
    Public is_monetary As Boolean 'No	Identifies if the element defines a monetary data type. This is a data type based on the XBRL monetaryItemType.

    Public Overrides Sub fillFieldList()
        Dim t As Type = Me.GetType
        fields.Add("element_id", "Primary key.", t)
        fields.Add("qname_id", "The id of the QName for the element.", t)
        fields.Add("datatype_qname_id", "The id of the QName of the element’s type.", t)
        fields.Add("xbrl_base_datatype_qname_id", "The id of the QName of the element’s base data type. This is the XBRL type that the element’s type is based upon. If the element directly uses an XBRL type, then this will be the same as the datatype_qname_id.", t)
        fields.Add("balance_id", "A code for the balance type of the element: 1 = debit 2 = credit These codes are defined in the enumeration_element_balance table. If there is no balance type, then this field is null.", t)
        fields.Add("period_type_id", "A code for the period type of the element: 1 = instant 2 = duration 3 = forever These codes are defined in the enumeration_element_period_type table.", t)
        fields.Add("substitution_group_qname_id", "The id of the QName of the element’s substitution group.", t)
        fields.Add("abstract", "Identifies if the element is defined as an abstract element.", t)
        fields.Add("nillable", "Identifies if the xsi:nillable attribute is set to true.", t)
        fields.Add("document_id", "The id of the document where the element is defined.", t)
        fields.Add("is_numeric", "Identifies if the element defines a numeric data type.", t)
        fields.Add("is_monetary", "Identifies if the element defines a monetary data type. This is a data type based on the XBRL monetaryItemType.", t)
    End Sub

    Public Overrides Sub fillLinkTables()
        linkTables.Clear()
        linkTables.Add("element_id", "element_attribute_value_association", "element_id")
        linkTables.Add("element_id", "element_attribute_value_association", "element_id")
        linkTables.Add("element_id", "fact", "element_id")
        linkTables.Add("element_id", "relationship", "from_element_id")
        linkTables.Add("element_id", "relationship", "to_element_id")
        linkTables.Add("qname_id", "qname", "qname_id")
        linkTables.Add("data_type_qname_id", "qname", "qname_id")
        linkTables.Add("xbrl_base_datatype_qname_id", "qname", "qname_id")
        linkTables.Add("balance_id", "enumeration_element_balance", "enumeration_element_balance_id")
        linkTables.Add("period_id", "enumeration_element_period_type", "enumeration_element_period_type_id")
        linkTables.Add("substitution_group_qname_id", "qname", "qname_id")
        linkTables.Add("document_id", "document", "document_id")

    End Sub


End Class
Public Class element_attribute_value_association
    Inherits sqlTable
    Public Sub New()
        MyBase.new("element_attribute_value_association")
        tableDescription = "The element_attribute_value_association table is used to link the element with the attribute_value."
    End Sub

    Public element_attribute_value_association_id As Integer 'No	Primary key.
    Public element_id As Integer 'No	The id of the element.
    Public attribute_value_id As Integer 'No	The id of the attribute value.

    Public Overrides Sub fillFieldList()
        Dim t As Type = Me.GetType
        fields.Add("element_attribute_value_association_id", "Primary key.", t)
        fields.Add("element_id", "The id of the element.", t)
        fields.Add("attribute_value_id", "The id of the attribute value.", t)
    End Sub


    Public Overrides Sub fillLinkTables()
        linkTables.Clear()
        linkTables.Add("element_id", "element", "element_id")
        linkTables.Add("attribute_value_id", "attribute_value", "attribute_value_id")
    End Sub

End Class
Public Class entity
    Inherits sqlTable
    Public Sub New()
        MyBase.new("entity")
        tableDescription = "The entity table lists the entities that have filed with the SEC. The 'entity_name' and 'entity_code' come from the first filing for the entity."
    End Sub

    Public entity_id As Integer 'No	Primary key.
    Public entity_code As String  'No	The CIK for the entity. This is derived from the entity identifier.
    Public authority_scheme As String  'No	The entity identifier scheme that is used in the context for the entity. The value for the entity identifier scheme is mandated in the EDGAR Filer Manual.
    Public entity_name As String  'No	The name of the entity. This is set from the first accession (filing)

    Public Overrides Sub fillFieldList()
        Dim t As Type = Me.GetType
        fields.Add("entity_id", "Primary key.", t)
        fields.Add("entity_code", "The CIK for the entity. This is derived from the entity identifier.", t)
        fields.Add("authority_scheme", "The entity identifier scheme that is used in the context for the entity. The value for the entity identifier scheme is mandated in the EDGAR Filer Manual.", t)
        fields.Add("entity_name", "The name of the entity. This is set from the first accession (filing) for the entity.", t)
    End Sub

    Public Overrides Sub fillLinkTables()
        linkTables.Clear()
        linkTables.Add("entity_id", "accession", "entity_id")
    End Sub



End Class
Public Class enumeration_arcrole_cycles_allowed
    Inherits sqlTable
    Public Sub New()
        MyBase.new("enumeration_arcrole_cycles_allowed")
        tableDescription = "The enumeration_arcrole_cycles_allowed table contains the list of values for the cycles allowed attribute on an arc role."
    End Sub

    Public enumeration_arcrole_cycles_allowed_id As Integer 'No	Primary key.
    Public description As String  'No	The CIK for the entity. This is derived from the entity identifier. 1 = any 2 = undirected 3 = none 

    Public Overrides Sub fillFieldList()
        Dim t As Type = Me.GetType
        fields.Add("enumeration_arcrole_cycles_allowed_id", "Primary key.", t)
        fields.Add("description", "The CIK for the entity. This is derived from the entity identifier. 1 = any 2 = undirected 3 = none", t)
    End Sub

    Public Overrides Sub fillLinkTables()
        linkTables.Clear()
        linkTables.Add("enumeration_arcrole_cycles_allowed_id", "custom_arcrole_type", "cycles_allowed")
    End Sub



End Class
Public Class enumeration_element_balance
    Inherits sqlTable
    Public Sub New()
        MyBase.new("enumeration_element_balance")
        tableDescription = "The enumeration_element_balance table contains the list of values for the balance type attribute on an element."
    End Sub

    Public enumeration_element_balance_id As Integer 'No	Primary key.
    Public description As String  'No	The CIK for the entity. This is derived from the entity identifier. 1 = debit 2 = credit 

    Public Overrides Sub fillFieldList()
        Dim t As Type = Me.GetType
        fields.Add("enumeration_element_balance_id", "Primary key.", t)
        fields.Add("description", "The CIK for the entity. This is derived from the entity identifier. 1 = debit 2 = credit", t)
    End Sub

    Public Overrides Sub fillLinkTables()
        linkTables.Clear()
        linkTables.Add("enumeration_element_balance_id", "element", "balance_id")
    End Sub




End Class
Public Class enumeration_element_period_type
    Inherits sqlTable
    Public Sub New()
        MyBase.new("enumeration_element_period_type")
        tableDescription = "The enumeration_element_period_type table contains the list of values for the period type attribute on an element."
    End Sub

    Public enumeration_element_period_type_id As Integer 'No	Primary key.
    Public description As String  'No	The CIK for the entity. This is derived from the entity identifier. 1 = instant 2 = duration 3 = forever 

    Public Overrides Sub fillFieldList()
        Dim t As Type = Me.GetType
        fields.Add("enumeration_element_period_type_id", "Primary key.", t)
        fields.Add("description", "The CIK for the entity. This is derived from the entity identifier. 1 = instant 2 = duration 3 = forever", t)
    End Sub

    Public Overrides Sub fillLinkTables()
        linkTables.Clear()
        linkTables.Add("enumeration_element_period_type_id", "element", "period_type_id")
    End Sub





End Class
Public Class enumeration_unit_measure_location
    Inherits sqlTable
    Public Sub New()
        MyBase.new("enumeration_unit_measure_location")
        tableDescription = "The enumeration_unit_measure_location table contains the list of values for the period type attribute on an element."
    End Sub

    Public enumeration_unit_measure_location_id As Integer 'No	Primary key.
    Public description As String  'No	The CIK for the entity. This is derived from the entity identifier.  1 = measure  	2 = numerator	'3 = denominator	

    Public Overrides Sub fillFieldList()
        Dim t As Type = Me.GetType
        fields.Add("enumeration_unit_measure_location_id", "Primary key.", t)
        fields.Add("description", "The CIK for the entity. This is derived from the entity identifier.  1 = measure  	2 = numerator	3 = denominator", t)
    End Sub

    Public Overrides Sub fillLinkTables()
        linkTables.Clear()
        linkTables.Add("enumeration_unit_measure_location_id", "unit_measure", "location_id")
    End Sub





End Class

Public Class fact
    Inherits sqlTable
    Public Sub New()
        MyBase.new("fact")
        tableDescription = "The fact table contains the facts for the filings. Because the same fact can be reported in multiple filings, there may be multiple versions of the same fact. For example, the year end value for assets for an entity will be reported for 2009 and then again for 2010 (for comparison in the filing). The fact table will contain a record for each reporting of the fact."
    End Sub

    Public fact_id As Integer 'No	Primary key.
    Public accession_id As Integer 'No	The id of the filing (accession) for the fact.
    Public context_id As Integer 'No	The id of the context for the fact.
    Public unit_id As Integer 'Yes	The id of the unit of measure for the fact. The value of this field for a non-numeric fact (which do not have a unit of measure) is null.
    Public element_id As Integer 'No	The id of the element that is the primary item (tag) of the fact.
    Public effective_value As Double 'Yes	For numeric fact, this is the value adjusted for the precision or decimals. For non-numeric facts this field is null.
    Public fact_value As String  'Yes	The text value of the fact as it appears in the instance document in the instantiation of the XBRL concept.

    Public Overrides Sub fillFieldList()
        Dim t As Type = Me.GetType
        fields.Add("fact_id", "Primary key.", t)
        fields.Add("accession_id", "The id of the filing (accession) for the fact.", t)
        fields.Add("context_id", "The id of the context for the fact.", t)
        fields.Add("unit_id", "The id of the unit of measure for the fact. The value of this field for a non-numeric fact (which do not have a unit of measure) is null.", t)
        fields.Add("element_id", "The id of the element that is the primary item (tag) of the fact.", t)
        fields.Add("effective_value", "For numeric fact, this is the value adjusted for the precision or decimals. For non-numeric facts this field is null.", t)
        fields.Add("fact_value", "The text value of the fact as it appears in the instance document in the instantiation of the XBRL concept.", t)
    End Sub

    Public Overrides Sub fillLinkTables()
        linkTables.Clear()
        linkTables.Add("fact_id", "fact_aug", "fact_id")
        linkTables.Add("accession_id", "accession", "accession_id")
        linkTables.Add("accession_id", "network", "accession_id")
        linkTables.Add("accession_id", "unit", "accession_id")
        linkTables.Add("context_id", "context", "context_id")
        linkTables.Add("context_id", "context_aug", "context_id")
        linkTables.Add("context_id", "context_dimension", "context_id")
        linkTables.Add("element_id", "element", "element_id")

    End Sub

End Class
Public Class fact_aug
    Inherits sqlTable
    Public Sub New()
        MyBase.new("fact_aug")
        tableDescription = "The fact_aug table contains additional information about a fact. There is a one-to-one relationship between the fact_aug and fact tables. The fact_aug table contains a hash for each fact based on the contextual information (including dimensions), the primary item and the unit of measure of the fact. This allows detection of duplicate facts (these are duplicates (duplicate item) as defined in the XBRL specification version 2.1)."
    End Sub

    Public fact_id As Integer 'No	Primary key.
    Public fact_hash As String 'No	A hash of the contextual information, the primary item and the unit of measure. The hash uses an assumption about extension concepts. The extension concepts for each filing (accession) use a namespace based on the filing. This prevents true comparison of extension concepts because in each filing for an entity the namespace is different. The uses the assumption that if the local name of an extension concept (primary, dimension and member) is the same between filings for the same entity that the concept is the same (as if the namespaces were the same). The hash is calculated using the hash_fact (integer) function. 
    Public ultimus_index As Integer 'Yes	The ultimus index ranks duplicate facts in order of the most recent filing. Facts with an ultimus index of “1” are the most recent reported value of the fact. The ultimus index is recalculated when a new duplicate fact is added to the database.
    Public current_index As Integer 'Yes	This field is not used.
    'not in doc!
    Public calendar_hash As String
    Public calendar_ultimus_index As Integer

    Public Overrides Sub fillFieldList()
        Dim t As Type = Me.GetType
        fields.Add("fact_id", "Primary key.", t)
        fields.Add("fact_hash", "A hash of the contextual information, the primary item and the unit of measure. The hash uses an assumption about extension concepts. The extension concepts for each filing (accession) use a namespace based on the filing. This prevents true comparison of extension concepts because in each filing for an entity the namespace is different. The uses the assumption that if the local name of an extension concept (primary, dimension and member) is the same between filings for the same entity that the concept is the same (as if the namespaces were the same). The hash is calculated using the hash_fact (integer) function. ", t)
        fields.Add("ultimus_index", "The ultimus index ranks duplicate facts in order of the most recent filing. Facts with an ultimus index of '1' are the most recent reported value of the fact. The ultimus index is recalculated when a new duplicate fact is added to the database.", t)
        fields.Add("current_index", "This field is not used.", t)
        'not in doc!
        fields.Add("calendar_hash", "!Not in Doc!", t)
        fields.Add("calendar_ultimus_index", "!Not in Doc!", t)
      

    End Sub

    Public Overrides Sub fillLinkTables()
        linkTables.Clear()
        linkTables.Add("fact_id", "fact", "fact_id")
    End Sub


End Class
Public Class label_resource
    Inherits sqlTable
    Public Sub New()
        MyBase.new("label_resource")
        tableDescription = "The label_resource table contains element labels. The label resource is linked to the element via the relationship table. The label_resoure table has a zero-to-one relationship with the resource table and uses the same primary key (resource_id)."
    End Sub

    Public resource_id As Integer 'No	Primary key.
    Public label As String  'No	The text of the label.
    Public xml_lang As String  'Yes	The language of the label. This is the ISO language code.

    Public Overrides Sub fillFieldList()
        Dim t As Type = Me.GetType
        fields.Add("resource_id", "Primary key.", t)
        fields.Add("label", "The text of the label.", t)
        fields.Add("xml_lang", "The language of the label. This is the ISO language code.", t)
    End Sub

    Public Overrides Sub fillLinkTables()
        linkTables.Clear()
        linkTables.Add("resource_id", "resource", "resource_id")
        linkTables.Add("resource_id", "relationship", "from_resource_id")
        linkTables.Add("resource_id", "relationship", "to_resource_id")

        'left out of doc
        linkTables.Add("resource_id", "reference_part", "resource_id")



    End Sub


End Class
Public Class _namespace
    Inherits sqlTable
    Public Sub New()
        MyBase.new("namespace")
        tableDescription = "The namespace table lists the namespaces of the standard taxonomies defined by the SEC. This is used to identify elements that are not extension elements. Currently, this table only includes the namespaces for standard taxonomies, but it may in the future include the namespaces for the extension taxonomies."
    End Sub

    Public namespace_id As Integer 'No	Primary key.
    Public uri As String  'Yes	The uri of the namespace.
    Public is_base As Boolean   'Yes	Identifies if the namespace is a base namespace. Since this table only contains “base” taxonomies (as defined by the SEC as standard taxonomies) this field is always set to true. However, non base namespaces may be added in the future. This field should be used to verify that the namespace is a base namespace.
    Public taxonomy_version_id As Integer 'Yes	The id of the taxonomy version that is related to the namespace. This is useful to identify which taxonomy and version that the namespace is associated to.


    Public Overrides Sub fillFieldList()
        Dim t As Type = Me.GetType
        fields.Add("namespace_id", "Primary key.", t)
        fields.Add("uri", "The uri of the namespace.", t)
        fields.Add("is_base", "Identifies if the namespace is a base namespace. Since this table only contains 'base' taxonomies (as defined by the SEC as standard taxonomies) this field is always set to true. However, non base namespaces may be added in the future. This field should be used to verify that the namespace is a base namespace.", t)
        fields.Add("taxonomy_version_id", "The id of the taxonomy version that is related to the namespace. This is useful to identify which taxonomy and version that the namespace is associated to.", t)
    End Sub

    Public Overrides Sub fillLinkTables()
        linkTables.Clear()
        linkTables.Add("taxonomy_version_id", "taxonomy_version", "taxonomy_version_id")
    End Sub

End Class
Public Class network
    Inherits sqlTable
    Public Sub New()
        MyBase.new("network")
        tableDescription = "The network table lists the networks that are in the linkbases of the filings (accessions). A network is identified by the following: * extended link element * extended link role * arc element * arc role The network table has a one-to-many relationship to the relationship table."
    End Sub

    Public network_id As Integer 'No	Primary key.
    Public accession_id As Integer 'No	The id of the filing (accession).
    Public extended_link_qname_id As Integer 'No	The id of the QName of the extended link element .
    Public extended_link_role_uri_id As Integer 'No	The id of the URI of the extended link role.
    Public arc_qname_id As Integer 'No	The id of the QName of the arc element.
    Public arcrole_uri_id As Integer 'No	The id of the URI of the arc role.
    Public description As String  'Yes	The description of the network. This is the text of the definition of the extended link role.


    Public Overrides Sub fillFieldList()
        Dim t As Type = Me.GetType
        fields.Add("network_id", "Primary key.", t)
        fields.Add("accession_id", "The id of the filing (accession).", t)
        fields.Add("extended_link_qname_id", "The id of the QName of the extended link element .", t)
        fields.Add("extended_link_role_uri_id", "The id of the URI of the extended link role.", t)
        fields.Add("arc_qname_id", "The id of the QName of the arc element.", t)
        fields.Add("arcrole_uri_id", "The id of the URI of the arc role.", t)
        fields.Add("description", "The description of the network. This is the text of the definition of the extended link role.", t)
    End Sub

    Public Overrides Sub fillLinkTables()
        linkTables.Clear()
        linkTables.Add("network_id", "relationship", "network_id")
        linkTables.Add("accession_id", "accession", "accession_id")
        linkTables.Add("extended_link_qname_id", "qname", "qname_id")
        linkTables.Add("extended_link_role_uri_id", "uri", "uri_id")
        linkTables.Add("arc_qname_id", "qname", "qname_id")
        linkTables.Add("arcrole_uri_id", "uri", "uri_id")
        linkTables.Add("accession_id", "fact", "accession_id") ' was missing from link tables!!!
    End Sub

End Class


Public Class qname
    Inherits sqlTable
    Public Sub New()
        MyBase.new("qname")
        tableDescription = "The qname table lists all the qualified names that are used in filings (accessions). Primarily, this is used for elements to identify the namespace and local name of the elements, however there are some non element qnames in the table (e.g. data types)."
    End Sub

    Public qname_id As Integer 'No	Primary key.
    Public _namespace As String  'Yes	The namespace portion of the qualified name.
    Public local_name As String  'No	The local name portion of the qualified name.

    Public Overrides Sub fillFieldList()
        Dim t As Type = Me.GetType
        fields.Add("qname_id", "Primary key.", t)
        fields.Add("namespace", "The namespace portion of the qualified name.", t)
        fields.Add("local_name", "The local name portion of the qualified name.", t)
    End Sub

    Public Overrides Sub fillLinkTables()
        linkTables.Clear()
        linkTables.Add("qname_id", "attribute_value", "qname_id")
        linkTables.Add("qname_id", "context_dimension", "dimension_qname_id")
        linkTables.Add("qname_id", "context_dimension", "member_qname_id")
        linkTables.Add("qname_id", "context_dimension", "typed_qname_id")
        linkTables.Add("qname_id", "custom_arcrole_used_on", "qname_id")
        linkTables.Add("qname_id", "custom_role_used_on", "qname_id")
        linkTables.Add("qname_id", "element", "qname_id")
        linkTables.Add("qname_id", "element", "datatype_qname_id")
        linkTables.Add("qname_id", "element", "xbrl_base_datatype_qname_id")
        linkTables.Add("qname_id", "element", "substitution_group_qname_id")
        linkTables.Add("qname_id", "network", "extended_link_qname_id")
        linkTables.Add("qname_id", "network", "arc_qname_id")
        linkTables.Add("qname_id", "reference_part", "qname_id")
        linkTables.Add("qname_id", "resource", "qname_id")
        linkTables.Add("qname_id", "unit_measure", "qname_id")
    End Sub

End Class
Public Class reference_part
    Inherits sqlTable
    Public Sub New()
        MyBase.new("reference_part")
        tableDescription = "The reference_part table lists the values of reference parts from the filings (accessions). The reference parts are organized into a single reference via the resource table. There is a zero-or-one-to-many relationship between the resource table and the reference_part table."
    End Sub

    Public reference_part_id As Integer 'No	Primary key.
    Public resource_id As Integer 'No	The id of the reference resource.
    Public value As String  'No	The value of the reference part.
    Public qname_id As Integer 'No	The id of the QName of the reference part element.

    Public Overrides Sub fillFieldList()
        Dim t As Type = Me.GetType
        fields.Add("reference_part_id", "Primary key.", t)
        fields.Add("resource_id", "The id of the reference resource.", t)
        fields.Add("value", "The value of the reference part.", t)
        fields.Add("qname_id", "The id of the QName of the reference part element.", t)
    End Sub

    Public Overrides Sub fillLinkTables()
        linkTables.Clear()
        linkTables.Add("resource_id", "resource", "resource_id")
        linkTables.Add("qname_id", "qname", "qname_id")

        'left out of doc!
        linkTables.Add("resource_id", "label_resource", "resource_id")


    End Sub

End Class
Public Class relationship
    Inherits sqlTable
    Public Sub New()
        MyBase.new("relationship")
        tableDescription = "The relationship table lists relationships defined in the linkbases of the filings (accessions). These relationships can be between concepts or between concepts and resources (often label and references). Relationships are organized under networks defined in the network table."
    End Sub

    Public relationship_id As Integer 'No	Primary key.
    Public network_id As Integer 'No	The id of the network for the relationship.
    Public from_element_id As Integer 'Yes	The id of the element on the “from” side of the relationship. If the relationship is from a resource then this field is null.
    Public to_element_id As Integer 'Yes	The id of the element on the “to” side of the relationship. If the relationship is to a resource then this field is null.
    Public reln_order As Double  'Yes	The relationship order. This is the value of the order attribute from the arc.
    Public from_resource_id As Integer 'Yes	The id of the resource on the “from” side of the relationship. If the relationship is from an element then this field is null.
    Public to_resource_id As Integer 'Yes	The id of the resource on the “to” side of the relationship. If the relationship is to an element then this field is null.
    Public calculation_weight As Double  'Yes	The value of the weight attribute if the relationship is based on a calculation arc, otherwise this field is null.
    Public tree_sequence As Integer 'No	The nodes of a network of relationships are sequentially ordered starting from the roots and working down the network in order of the relationship order of the children. This essentially creates an ordered sequence of nodes of the network similar to document order of an XML hierarchy.
    Public tree_depth As Integer 'No	The depth of the child node of the relationship.
    Public preferred_label_role_uri_id As Integer 'Yes	The id of the URI of the role for the preferred label if there is one on a presentation arc, otherwise this field is null.

    Public Overrides Sub fillFieldList()
        Dim t As Type = Me.GetType
        fields.Add("relationship_id", "Primary key.", t)
        fields.Add("network_id", "The id of the network for the relationship.", t)
        fields.Add("from_element_id", "The id of the element on the 'from' side of the relationship. If the relationship is from a resource then this field is null.", t)
        fields.Add("to_element_id", "The id of the element on the 'to' side of the relationship. If the relationship is to a resource then this field is null.", t)
        fields.Add("reln_order", "The relationship order. This is the value of the order attribute from the arc.", t)
        fields.Add("from_resource_id", "The id of the resource on the 'from' side of the relationship. If the relationship is from an element then this field is null.", t)
        fields.Add("to_resource_id", "The id of the resource on the 'to' side of the relationship. If the relationship is to an element then this field is null.", t)
        fields.Add("calculation_weight", "The value of the weight attribute if the relationship is based on a calculation arc, otherwise this field is null.", t)
        fields.Add("tree_sequence", "The nodes of a network of relationships are sequentially ordered starting from the roots and working down the network in order of the relationship order of the children. This essentially creates an ordered sequence of nodes of the network similar to document order of an XML hierarchy.", t)
        fields.Add("tree_depth", "The depth of the child node of the relationship.", t)
        fields.Add("preferred_label_role_uri_id", "The id of the URI of the role for the preferred label if there is one on a presentation arc, otherwise this field is null.", t)
    End Sub

    Public Overrides Sub fillLinkTables()
        linkTables.Clear()
        linkTables.Add("network_id", "network", "network_id")
        linkTables.Add("from_element_id", "element", "element_id")
        linkTables.Add("to_element_id", "element", "element_id")
        linkTables.Add("from_resource_id", "resource", "resource_id")
        linkTables.Add("to_resource_id", "resource", "resource_id")
        linkTables.Add("preferred_label_role_uri_id", "uri", "uri_id")

        ' not in docu!
        linkTables.Add("from_resource_id", "label_resource", "resource_id")
        linkTables.Add("to_resource_id", "label_resource", "resource_id")



    End Sub

End Class
Public Class resource
    Inherits sqlTable
    Public Sub New()
        MyBase.new("resource")
        tableDescription = "The resource table lists the resources that participate in a relationship. Resources are usually either label or reference resources. When it is a label resource there will be a corresponding row in label_resource table."
    End Sub

    Public resource_id As Integer 'No	Primary key.
    Public role_uri_id As Integer 'No	The id of the role URI on the resource.
    Public qname_id As Integer 'No	The id of the QName of the resource element.
    Public document_id As Integer 'No	The id of the document where the resource is located.
    Public document_line_number As Integer 'No	The line number in the document where the resource is located.
    Public document_column_number As Integer 'No	The character location on the line identified in the document_line_number field where the resource is located.


    Public Overrides Sub fillFieldList()
        Dim t As Type = Me.GetType
        fields.Add("resource_id", "Primary key.", t)
        fields.Add("role_uri_id", "The id of the role URI on the resource.", t)
        fields.Add("qname_id", "The id of the QName of the resource element.", t)
        fields.Add("document_id", "The id of the document where the resource is located.", t)
        fields.Add("document_line_number", "The line number in the document where the resource is located.", t)
        fields.Add("document_column_number", "The character location on the line identified in the document_line_number field where the resource is located.", t)
    End Sub

    Public Overrides Sub fillLinkTables()
        linkTables.Clear()
        linkTables.Add("resource_id", "label_resource", "resource_id")
        linkTables.Add("role_uri_id", "uri", "uri_id")
        linkTables.Add("qname_id", "qname", "qname_id")
        linkTables.Add("document_id", "document", "document_id")
        'these were left out:
        linkTables.Add("resource_id", "relationship", "from_resource_id")
        linkTables.Add("resource_id", "relationship", "to_resource_id")

        linkTables.Add("resource_id", "reference_part", "resource_id")

    End Sub


End Class
Public Class sic_code
    Inherits sqlTable
    Public Sub New()
        MyBase.new("sic_code")
        tableDescription = "The sic_code table lists the industry SIC codes that are used by filings (accessions)."
    End Sub

    Public sic_code_id As Integer 'No	Primary key. This is unlike other primary keys which are built sequentially as an internal identifier. This case, this field is the actual sic code.
    Public description As String  'No	The text description of the industry classification.

    Public Overrides Sub fillFieldList()
        Dim t As Type = Me.GetType
        fields.Add("sic_code_id", "Primary key. This is unlike other primary keys which are built sequentially as an internal identifier. This case, this field is the actual sic code.", t)
        fields.Add("description", "The text description of the industry classification.", t)
    End Sub

    Public Overrides Sub fillLinkTables()
        linkTables.Clear()
        linkTables.Add("sic_code_id", "accession", "standard_industrial_classification")
    End Sub


End Class

Public Class taxonomy
    Inherits sqlTable
    Public Sub New()
        MyBase.new("taxonomy")
        tableDescription = "The taxonomy table lists the standard taxonomies defined by the SEC. In this case, a taxonomy is vernacular use of the word 'taxonomy' which is really the DTS of a standard taxonomy. For example, 'US GAAP' is really the DTS of the US GAAP taxonomies. This table lists just the standard DTSs."
    End Sub

    Public taxonomy_id As Integer 'No	Primary key.
    Public name As String  'No	The descriptive name of the taxonomy.

    Public Overrides Sub fillFieldList()
        Dim t As Type = Me.GetType
        fields.Add("taxonomy_id", "Primary key.", t)
        fields.Add("name", "The descriptive name of the taxonomy.", t)
    End Sub

    Public Overrides Sub fillLinkTables()
        linkTables.Clear()
        linkTables.Add("taxonomy_id", "taxonomy_version", "taxonomy_id")
    End Sub


End Class
Public Class taxonomy_version
    Inherits sqlTable
    Public Sub New()
        MyBase.new("taxonomy_version")
        tableDescription = "The taxonomy_version table lists the different releases of the taxonomies in the taxonomy table."
    End Sub

    Public taxonomy_version_id As Integer 'No	Primary key.
    Public taxonomy_id As Integer 'No	The id of the taxonomy (DTS).
    Public version As String  'No	The description of the version. This is usually the year when the taxonomy (DTS) is release.

    Public Overrides Sub fillFieldList()
        Dim t As Type = Me.GetType
        fields.Add("taxonomy_version_id", "Primary key.", t)
        fields.Add("taxonomy_id", "The id of the taxonomy (DTS).", t)
        fields.Add("version", "The description of the version. This is usually the year when the taxonomy (DTS) is release.", t)
    End Sub

    Public Overrides Sub fillLinkTables()
        linkTables.Clear()
        linkTables.Add("taxonomy_version_id", "namespace", "taxonomy_version_id")
        linkTables.Add("taxonomy_id", "taxonomy", "taxonomy_id")
    End Sub


End Class
Public Class unit
    Inherits sqlTable
    Public Sub New()
        MyBase.new("unit")
        tableDescription = "The unit table lists the units used by facts. The measure for the unit is in the related unit_measure table."
    End Sub

    Public unit_id As Integer 'No	Primary key.
    Public accession_id As Integer 'No	The id of the filing (accession) that contains the unit.
    Public unit_xml_id As String  'No	The XML id of the unit element.

    Public Overrides Sub fillFieldList()
        Dim t As Type = Me.GetType
        fields.Add("unit_id", "Primary key.", t)
        fields.Add("accession_id", "The id of the filing (accession) that contains the unit.", t)
        fields.Add("unit_xml_id", "The XML id of the unit element.", t)
    End Sub

    Public Overrides Sub fillLinkTables()
        linkTables.Clear()
        linkTables.Add("unit_id", "fact", "unit_id")
        linkTables.Add("unit_id", "unit_measure", "unit_id")
        linkTables.Add("accession_id", "accession", "accession_id") ' missing from pdf doc!
    End Sub


End Class


Public Class unit_measure
    Inherits sqlTable
    Public Sub New()
        MyBase.new("unit_measure")
        tableDescription = "The unit_measure table identifies the unit of measure for a unit. A unit of measure can be a simple QName or comprised of a numerator and denominator, each of which are QNames."
    End Sub

    Public unit_meassure_id As Integer 'No	Primary key.
    Public unit_id As Integer 'No	The id of the unit.
    Public qname_id As Integer 'No	The QName of the unit_measure component.
    Public location_id As XBRL.unit_measure_location  'Yes	This identifies if the measure is basic measure or the numerator or denominator of a complex measure. The codes are: 1 = measure – this is a basic unit of measure 2 = numerator 3 = denominator This code is defined in the enumeration_unit_measure_location. 

    Public Overrides Sub fillFieldList()
        Dim t As Type = Me.GetType
        fields.Add("unit_meassure_id", "Primary key.", t)
        fields.Add("unit_id", "The id of the unit.", t)
        fields.Add("qname_id", "The QName of the unit_measure component.", t)
        fields.Add("location_id", "This identifies if the measure is basic measure or the numerator or denominator of a complex measure. The codes are: 1 = measure – this is a basic unit of measure 2 = numerator 3 = denominator This code is defined in the enumeration_unit_measure_location.", t)
    End Sub

    Public Overrides Sub fillLinkTables()
        linkTables.Clear()
        linkTables.Add("unit_id", "fact", "unit_id")
        linkTables.Add("unit_id", "unit", "unit_id")
        linkTables.Add("qname_id", "qname", "qname_id")
        linkTables.Add("location_id", "enumeration_unit_measure_location", "enumeration_unit_measure_location_id")
    End Sub


End Class
Public Class uri
    Inherits sqlTable
    Public Sub New()
        MyBase.new("uri")
        tableDescription = "The uri table lists the URIs that are used in the filings (accessions)."
    End Sub

    Public uri_id As Integer 'No	Primary key.
    Public uri As String  'No	The URI string.

    Public Overrides Sub fillFieldList()
        Dim t As Type = Me.GetType
        fields.Add("uri_id", "Primary key.", t)
        fields.Add("uri", "The URI string.", t)
    End Sub

    Public Overrides Sub fillLinkTables()
        linkTables.Clear()
        linkTables.Add("uri_id", "custom_role_type", "unit_id")
        linkTables.Add("uri_id", "custom_role_type", "unit_id")
        linkTables.Add("uri_id", "network", "extended_link_role_uri_id")
        linkTables.Add("uri_id", "network", "arcrole_uri_id")
        linkTables.Add("uri_id", "relationship", "preferred_label_role_uri_id")
        linkTables.Add("uri_id", "resource", "role_uri_id")
    End Sub


End Class
